﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DomainModel;
using Utils;
using WebUI.Utils;

namespace WebUI.Models
{
    public class HomeViewModel: BaseViewModel
    {
        private int _numPerPage = 12;

        public HomeViewModel()
            : base()
        { }

        public List<LatestJob> LatestJobList { get; set; }
        public List<LatestShot> LatestShotList { get; set; }

        protected override void SetVars()
        {
            LatestJobList = DataUtils.GetList<LatestJob>(ConstUtils.SP_GetLatestJobs, new { Top = 12 });
            LatestShotList = DataUtils.GetList<LatestShot>(ConstUtils.SP_GetLatestShots, new { Page = 1, NumPerPage = _numPerPage });

            foreach (var shot in LatestShotList)
            {
                shot["AvatarUrl"] = ImageUtils.GetAvatarRelativeUrl(AvatarType.IndAvatar, shot.IndID, AvatarSizeEnum.Avatar_16x16, shot.AvatarFileExtension);
                shot["ShotUrl"] = ImageUtils.GetShotRelativeUrl(shot.IndID, shot.ShotID, ShotSizeEnum.Shot_200x133, shot.FileExtension);
            }
        }
    }
}